//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
/******************************************************************************
** INTEL CONFIDENTIAL
** Copyright 2000-2003 Intel Corporation All Rights Reserved.
**
** The source code contained or described herein and all documents
** related to the source code (Material) are owned by Intel Corporation
** or its suppliers or licensors.  Title to the Material remains with
** Intel Corporation or its suppliers and licensors. The Material contains
** trade secrets and proprietary and confidential information of Intel
** or its suppliers and licensors. The Material is protected by worldwide
** copyright and trade secret laws and treaty provisions. No part of the
** Material may be used, copied, reproduced, modified, published, uploaded,
** posted, transmitted, distributed, or disclosed in any way without Intel
** prior express written permission.

** No license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise. Any license under such intellectual property rights
** must be express and approved by Intel in writing.
********************************************************************************/
#ifndef __XLLP_CAMERA_OS_DEPEND_H__
#define __XLLP_CAMERA_OS_DEPEND_H__

#include "xllp_defs.h"
#include "xllp_dmac.h"
#include "xllp_ost.h"
#include "xllp_i2c.h"

/**************************
 * Time API
 **************************/
void OS_Delay(int ms);

void InitRegs(XLLP_OST_T *pOST, XLLP_I2C_T *pI2C);

/**************************
 * I2C API
 **************************/
// Write "bytesCount" data from "bytesBuf" to slave device "slaveAddr", Return: 0-success, non-0: error
int OS_I2CMasterWriteData(XLLP_UINT8_T slaveAddr, const XLLP_UINT8_T * bytesBuf, int bytesCount);

// Read "bufLen" data to "bytesBuf" to slave device "slaveAddr", Return: 0-success, non-0: error
int OS_I2CMasterReadData(XLLP_UINT8_T slaveAddr, XLLP_UINT8_T * bytesBuf, int bufLen);

/**************************
 * DMA API
 **************************/
// Allocate one DMA channel with desired priority
XLLP_STATUS_T OS_DmaAllocChannel(P_XLLP_DMAC_CHANNEL_T pChannel, XLLP_DMAC_CHANNEL_PRIORITY_T aChannelPriority);

// Free the channel and the request to channel mapping
void OS_DmaFreeChannel(XLLP_DMAC_CHANNEL_T aChannel, XLLP_DMAC_DEVICE_T aDevice);

// Fill the channel dma register with the descriptor, Set up device request to channel mapping, Set up proper alignment
// Note: Both virtual and physical address of descriptor is required to facilitate any implementation.
void OS_DmaCfgChannelDescTransfer(  P_XLLP_DMAC_DESCRIPTOR_T pDescVir, P_XLLP_DMAC_DESCRIPTOR_T pDescPhy,
                                    XLLP_DMAC_CHANNEL_T aChannel,
                                    XLLP_DMAC_DEVICE_T aDevice,
                                    XLLP_DMAC_ALIGNMENT_T aLignment);

// Start the specified channel
void OS_DmaStartTransfer(XLLP_DMAC_CHANNEL_T aChannel);

// Stop the specified channel
void OS_DmaStopTransfer(XLLP_DMAC_CHANNEL_T aChannel);

#endif
